$(function() {

  //滚动条拉到底部的时候去获取新的数据
  var stop=true; 
  var pageNumb = 1;

  var url = jumpUrl+'/lawyer/'+id+'/cases?page='+pageNumb++;
  init(url);
  $(window).scroll(function(e){ 
      var totalheight = parseFloat($(window).height()) + parseFloat($(window).scrollTop()); 
      if($(document).height() <= totalheight){ 
          if(stop==true){ 
              stop=false;  
              init(url);
          } 
      } 
      stopDefault(e);
  });
  

  function init(url){
    //跳转到案例详情
    var str = "";
    $(".lvartivleShare").empty();
    var loading = layer.msg('加载中...', {icon: 16});
    $.get(url, function(data){
          
    }, "json").error(function(data) {
             alert('超时');    
    }).success(function(data) {
          var obj = data.data;
          if(obj.length >= 10){
            for(var i=0; i<obj.length; i++)  
            {  
              obj[i].view_count == undefined ? obj[i].view_count =0 : obj[i].view_count;
              obj[i].likes_count == undefined ? obj[i].likes_count =0 : obj[i].likes_count;
              obj[i].comments_count == undefined ? obj[i].comments_count =0 : obj[i].comments_count;
              str +='<dl class="artivleSharelist clear">'
                  str +='<dt><a href="'+jumpUrl+'/lawyer/'+obj[i].id+'/cases"><img class="userImg" src="'+jumpUrl+obj[i].avatar+'" width="100" height="100" alt="" /></a></dt>'
                  str +='<dd class="title"><a href="'+jumpUrl+'/lawyer/'+obj[i].id+'/cases"><b>婚姻家庭</b></a></dd>'
                  str +='<dd class="issuetxt"></dd>'
                  str +='<dd>'
                      str +='<label class="dateTime">'+obj[i].post_extra.created_at+'</label>'
                      str +='<div class="numlr">'
                          str +='<a href="javascript:void(0);" title="阅读"><label class="readNumber">'+obj[i].view_count+'</label></a><b class="line">|</b>'
                              str +='<a href="javascript:void(0);" title="点赞"><label class="like">'+obj[i].likes_count+'</label></a><b class="line">|</b>'
                              str +='<a href="javascript:void(0);" title="评论"><label class="review last">'+obj[i].comments_count+'</label></a>'
                      str +='</div>'
                  str +='</dd>'
              str +='</dl>';
            }
            $(".lvartivleShare").append(str);
            layer.close(loading);
            console.info($("#page dl").length)
          }else{
            layer.close(loading); 
            layer.msg("暂无数据！");
            $(window).unbind('scroll');
          }
    });
  }
    

});